import 'package:flutter/material.dart';

class DefineButton extends StatelessWidget {

  const DefineButton({Key? key,this.colors, this.width,this.height,this.radius,this.tapCallback,this.margin,required this.child}):super(key: key);

  final List<Color>? colors;

  final double? width;
  final double? height;

  final BorderRadius? radius;

  final EdgeInsetsGeometry? margin;

  final GestureTapCallback? tapCallback;

  final Widget child;

  @override
  Widget build(BuildContext context) {
    ThemeData theme = Theme.of(context);
    List<Color> _colors = colors ?? [theme.primaryColor,theme.primaryColorLight];
    return Container(
           margin: margin,
           child: DecoratedBox(
           decoration: BoxDecoration(gradient: LinearGradient(colors: _colors),borderRadius: radius),
           child: Material(
              type: MaterialType.transparency,
              child: InkWell(
                splashColor: _colors.last,
                highlightColor: Colors.transparent,
                borderRadius: radius,
                onTap: tapCallback,
                child: ConstrainedBox(
                  constraints: BoxConstraints.tightFor(width: width,height: height),
                  child: Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Center(
                      child: DefaultTextStyle(
                        style: const TextStyle(fontWeight: FontWeight.bold),
                        child: child,
                      ),
                    ),
                  ),
                ),
              ),
          ),
       ),
    );
  }
}
